package com.struts.utils;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;

/**
 * Created by Administrator on 2015/2/5.
 */
public class FrameWork {
    public FrameWork() {
    }

    public   static ActionForm FullBeans(String fromPath,HttpServletRequest request){

        ActionForm  actionForm =null;

        try{

            Class clazz = Class.forName(fromPath);

            actionForm =(ActionForm)clazz.newInstance();

            Field[] fields_arry = clazz.getDeclaredFields();

            for (Field field :fields_arry){

                field.setAccessible(false);
                field.set(actionForm,request.getParameter(field.getName()));
                field.setAccessible(true);
            }

        }catch (Exception e){
            e.printStackTrace();
        }

        return actionForm;


    }
}
